<?php
namespace Api\Model;



class CommentModel extends BaseModel {

    private static $instance;

    public static function singleton()
    {
        self::$instance === null and self::$instance = new self();
        return self::$instance;
    }

    public function getListByRecordId($record_id){
        $where['record_id']=$record_id;
        $where['isshow']=1;
        $rows = $this->where($where)->order('comment_date desc')->select();
        foreach ($rows as $key=>$row){
            $rows[$key]['create_at']=date('Y-m-d');
        }
        $rows || $rows=[];
        return $rows;
    }

    public function hasComment($record_id){
        $where['record_id']=$record_id;
        $rows = $this->where($where)->find();
        if($rows){
            return 1;
        }else{
            return 0;
        }

    }
}